package ar.edu.utn.frsf.cidisi.upcolbpip2pn.generator.petrinet;

public class Transition2PN
{
  protected static String nl;
  public static synchronized Transition2PN create(String lineSeparator)
  {
    nl = lineSeparator;
    Transition2PN result = new Transition2PN();
    nl = null;
    return result;
  }

  public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
  protected final String TEXT_1 = "      <trans id=\"";
  protected final String TEXT_2 = "\"" + NL + "             explicit=\"false\">" + NL + "        <posattr x=\"-140.000000\"" + NL + "                 y=\"201.000000\"/>" + NL + "        <fillattr colour=\"White\"" + NL + "                  pattern=\"\"" + NL + "                  filled=\"false\"/>" + NL + "        <lineattr colour=\"Black\"" + NL + "                  thick=\"1\"" + NL + "                  type=\"solid\"/>" + NL + "        <textattr colour=\"Black\"" + NL + "                  bold=\"false\"/>" + NL + "        <text>";
  protected final String TEXT_3 = "</text>" + NL + "        <box w=\"60.000000\"" + NL + "             h=\"40.000000\"/>";
  protected final String TEXT_4 = NL + "        <subst subpage=\"";
  protected final String TEXT_5 = "\"" + NL + "               portsock=\"(";
  protected final String TEXT_6 = ",";
  protected final String TEXT_7 = ")(";
  protected final String TEXT_8 = ",";
  protected final String TEXT_9 = ")\">" + NL + "          <subpageinfo id=\"";
  protected final String TEXT_10 = "\"" + NL + "                       name=\"";
  protected final String TEXT_11 = "\">" + NL + "            <posattr x=\"-140.000000\"" + NL + "                     y=\"177.000000\"/>" + NL + "            <fillattr colour=\"White\"" + NL + "                      pattern=\"Solid\"" + NL + "                      filled=\"false\"/>" + NL + "            <lineattr colour=\"Black\"" + NL + "                      thick=\"0\"" + NL + "                      type=\"Solid\"/>" + NL + "            <textattr colour=\"Black\"" + NL + "                      bold=\"false\"/>" + NL + "          </subpageinfo>" + NL + "        </subst>";
  protected final String TEXT_12 = NL + "        <binding x=\"7.200000\"" + NL + "                 y=\"-3.000000\"/>" + NL + "      </trans>" + NL;
  protected final String TEXT_13 = NL;

  public String generate(Object argument)
  {
    final StringBuffer stringBuffer = new StringBuffer();
     Transition transition = (Transition) argument; 
    
	SubPage subPage = transition.getSubPage();

    stringBuffer.append(TEXT_1);
    stringBuffer.append( transition.getId());
    stringBuffer.append(TEXT_2);
    stringBuffer.append( transition.getText());
    stringBuffer.append(TEXT_3);
    if (subPage != null){
    stringBuffer.append(TEXT_4);
    stringBuffer.append( subPage.getId());
    stringBuffer.append(TEXT_5);
    stringBuffer.append( subPage.getSubnetInput().getId());
    stringBuffer.append(TEXT_6);
    stringBuffer.append( subPage.getTransitionInput().getId());
    stringBuffer.append(TEXT_7);
    stringBuffer.append( subPage.getSubnetOutput().getId());
    stringBuffer.append(TEXT_8);
    stringBuffer.append( subPage.getTransitionOutput().getId());
    stringBuffer.append(TEXT_9);
    stringBuffer.append( subPage.getInfoId());
    stringBuffer.append(TEXT_10);
    stringBuffer.append( transition.getText());
    stringBuffer.append(TEXT_11);
    }
    stringBuffer.append(TEXT_12);
    stringBuffer.append(TEXT_13);
    return stringBuffer.toString();
  }
}
